]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/bluetooth: Fix wedged state
authorBastien Nocera <hadess@hadess.net>
Tue, 18 Jan 2022 10:14:47 +0000 (11:14 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 8 Feb 2022 23:16:46 +0000 (23:16 +0000)
Fix a state where toggling the main Bluetooth switch in the header will
always show the "Bluetooth Off" menu header with "Turn Off" as the only
option.

To reproduce, with Bluetooth enabled and working, run
"hciconfig hci0 down" as root, and check the status menu.

See gnome-bluetooth!102 and gnome-control-center!1148

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4857
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2055>

js/ui/status/bluetooth.js

index 3e49a5591de5af81411557be8b40f00a61409d6d..d1304cac555857c47a1c5c88c66114d70d9415f5 100644 (file)
@@ -25,6 +25,7 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._indicator = this._addIndicator();
         this._indicator.icon_name = 'bluetooth-active-symbolic';
         this._hadSetupDevices = global.settings.get_boolean(HAD_BLUETOOTH_DEVICES_SETUP);
+        this._client = new GnomeBluetooth.Client();
 
         this._proxy = new RfkillManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH,
                                              (proxy, error) => {
@@ -43,6 +44,8 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._toggleItem = new PopupMenu.PopupMenuItem('');
         this._toggleItem.connect('activate', () => {
             this._proxy.BluetoothAirplaneMode = !this._proxy.BluetoothAirplaneMode;
+            if (!this._proxy.BluetoothAirplaneMode)
+                this._client.default_adapter_powered = true;
         });
         this._item.menu.addMenuItem(this._toggleItem);
 
@@ -52,7 +55,6 @@ class Indicator extends PanelMenu.SystemIndicator {
         this._syncId = 0;
         this._adapter = null;
 
-        this._client = new GnomeBluetooth.Client();
         this._store = this._client.get_devices();
         this._deviceNotifyConnected = [];
         this._client.connect('device-removed', (c, path) => {
@@ -146,6 +148,6 @@ class Indicator extends PanelMenu.SystemIndicator {
         else
             this._item.label.text = _('Bluetooth On');
 
-        this._toggleItem.label.text = this._proxy.BluetoothAirplaneMode ? _('Turn On') : _('Turn Off');
+        this._toggleItem.label.text = this._client.default_adapter_powered ? _('Turn Off') : _('Turn On');
     }
 });